package com.hboxs.asl.controller.app.index;

import com.hboxs.asl.JsonMessage;
import com.hboxs.asl.controller.app.BaseController;
import com.hboxs.asl.entity.Message;
import com.hboxs.asl.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by xxx on 2016/11/25.
 * Controller -- 消息管理
 */
@Controller(value = "appMessageController")
@RequestMapping(value = "/app/message")
public class MessageController extends BaseController {


    @Resource(name = "messageServiceImpl")
    private MessageService messageService;
    @Resource(name = "memberServiceImpl")
    private MemberService memberService;

    /**
     * 消息
     */
    @RequestMapping(value = "/myMessage", method = RequestMethod.GET)
    public
    @ResponseBody
    Object myMessage(HttpServletRequest request) {
        List<Message> ms = messageService.findByMember(memberService.getCurrentByToken());
        return JsonMessage.success(ms);
    }


    /**
     * test
     *
     */
    @RequestMapping(value = "/test", method = RequestMethod.GET)
    public
    @ResponseBody
    Object test(HttpServletRequest request) {
         messageService.addMessage(memberService.getCurrentByToken(),"xxxxxx" ,"yyyyyyyyyy");
        return "123";
    }


}
